package main

import (
	"os"

	"dynamic-private/build"
	"dynamic-private/cmd"

	"github.com/tristin2024/logs"
	"github.com/urfave/cli/v2"
)

const (
	service = "dynamic-private"
)

func main() {
	local := []*cli.Command{}
	app := &cli.App{
		Name:                 service,
		Usage:                "backend service",
		Version:              build.Version(),
		EnableBashCompletion: true,
		Commands:             local,
		Flags: []cli.Flag{
			&cli.StringFlag{
				Name:  "ip",
				Usage: "listen on address",
				Value: "0.0.0.0",
			},
			&cli.IntFlag{
				Name:  "port",
				Usage: "listen on address",
				Value: 80,
			},
		},
		Action: cmd.Run,
	}
	app.Setup()
	if err := app.Run(os.Args); err != nil {
		logs.Std.Errorf("启动服务失败: %v", err)
		os.Exit(-1)
	}
}
